<?php
	session_start();
	include('connect.php');
	if(isset($_POST['logout'])){
		session_destroy();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div class="swap">

<?php
	
	if(isset($_POST['log'])){
		$user=$_POST['user'];
		$pass=SHA1($_POST['pass']);
		$q="select * from user where TenDN='$user' and Matkhau='$pass';";
		$r=mysqli_query($dbc,$q);
		if(mysqli_affected_rows($dbc)){
			$f=mysqli_fetch_array($r);
			$_SESSION['usn']=$f['Hoten'];
			$_SESSION['tdn']=$f['TenDN'];
			include('ad.php');
		}
		else{
			include('dangnhap.php');
			echo "User or Pass invalid! Try again..";
		}
	}elseif(isset($_GET['nav'])){
			if($_GET['nav']=='ad'){
				include('ad.php');
			}else{
				
			}
	}else{
		include('../../../trangadmin/index.php');
	}
?>
</div>

</body>
</html>